package java_thinking.unit_19._19_1_6;

import static common.util.Print.print;

/**
 * @Desc:   使用import导入枚举，但是好像现在不用显示的import了
 * @author: cww
 * @DateTime: 2019/5/22 9:25
 */

public class E01_TrafficLight2 {
    Signal color = Signal.RED;

    /**
     * 不需要default语句了
     */
    public void change() {
        switch (color) {
            case RED: color = Signal.GREEN;
                break;
            case GREEN: color = Signal.YELLOW;
                break;
            case YELLOW: color = Signal.RED;
                break;
        }
    }

    @Override
    public String toString() {
        return "TrafficLight{" +
                "color=" + color +
                '}';
    }

    public static void main(String[] args) {
        TrafficLight t = new TrafficLight();
        for (int i = 0; i < 7; i++) {
            print(t);
            t.change();
        }
    }
}
